<?php
	require ('db.class.php');
	require ('db.conf.php');
	
	$vars = $_POST;
	
	$db = new db();
	$db->user = $DBconf['user'];
	$db->pass = $DBconf['pass'];
	$db->server = $DBconf['server'];
	$db->database = $DBconf['dbname'];
	$db->connect();
	
	$ret = $db->execute("SELECT * FROM usuarios WHERE usuario='".$vars['user']."'");
	
	$row = $ret[0];
	if(md5($vars['pass']) == $row->password) {
		session_start();
		echo $row->usuario;
		$_SESSION['username'] = $row->usuario;
		$_SESSION['logged'] = true;
		header('location: ../index.php');
	} else
		header('location: ../login.php');
?>